/**
 * @name         RepNET Authentication Password Checker
 * @version      1.0a
 * @author       Kasun Rathnayaka <kazar55@gmail.com>
 * @about        Developed by MiDi
 * @license	 http://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License (LGPL)
 * @lastModified 2012.09.24
 */
package com.midi.wholesale.main;

import javax.swing.JOptionPane;
import javax.swing.JPasswordField;

import com.midi.wholesale.ui.AddToLorry;

public class PasswordChecker {

	@SuppressWarnings("unused")
	public static boolean checkResult(int id) {
		String passwordIn = "";
		boolean check = false;
		// passwordIn = JOptionPane.showInputDialog("Enter your password:");
		// passwordIn = JOptionPane.showInputDialog("Enter your password:");

		JPasswordField jpf = new JPasswordField();

		JOptionPane.showConfirmDialog(null, jpf, "Password:",
				JOptionPane.OK_CANCEL_OPTION);
		jpf.requestFocusInWindow();
		char[] arr = jpf.getPassword();

		for (int i = 0; i < arr.length; i++) {
			passwordIn = passwordIn + arr[i];
		}
		if (passwordIn == null) {

			check = false;

		}

		else {

			System.out.println("$$$$$$$$$$$$$$$$$$$$$$$" + passwordIn);

			String returnPassWord = addElements.getPassword(id);
			if (passwordIn.equalsIgnoreCase(returnPassWord)) {

				check = true;
			}

		}
		return check;

	}

}
